<template>
  <div>
    <el-container>
      <!--    侧边栏-->
      <el-aside :width="asidwidth" style="min-height: 110vh;background-color:#1f2341">
        <div
            style="height: 80px;line-height: 20px;background-color :rebeccapurple ;color: aliceblue; display: flex;align-items: center;justify-content: center">
          <img src="../assets/logo1.jpg" alt="" style="width: 40px;height: 40px">
          <span class="logo-title" v-show="!isCollapse">编程协会</span>
        </div>

        <el-menu :collapse="isCollapse" :collapse-transition="false" router background-color="#1f2341"
                 text-color="rgba(255,255,255,0.65)" active-text-color="#fff" style="border: none"
                 :default-active="$route.path">
          <el-submenu index="1-0">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">系统管理</span>
            </template>
            <el-menu-item>用户管理</el-menu-item>
            <el-menu-item>角色管理</el-menu-item>
            <el-menu-item>权限管理</el-menu-item>
            <el-menu-item>系统日志</el-menu-item>
            <el-menu-item>系统帮助</el-menu-item>

          </el-submenu>
          <el-menu-item index="/">主页</el-menu-item>
          <el-menu-item index="/element">打卡</el-menu-item>
          <el-menu-item>活动</el-menu-item>
          <el-menu-item>信息</el-menu-item>
          <el-menu-item>人员</el-menu-item>

        </el-menu>
      </el-aside>
      <el-container>
        <!-- 头部区域-->
        <el-header style="display: flex">
          <i :class="collapseiocn" style="font-size: 25px;" @click="handlecollapse"></i>

          <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 20px;flex-grow: 1">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item :to="{ path: 'user' }">活动管理</el-breadcrumb-item>
          </el-breadcrumb>

          <!-- 下拉菜单 -->

          <el-dropdown placement="bottom" trigger="click">
            <div style="display: flex; align-items: center; cursor: pointer;">
              <img src="../assets/logo1.jpg" alt="" style="width: 40px; height: 40px; margin-right: 10px;">
              <span >用户名</span>
            </div>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人信息</el-dropdown-item>
              <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
              <el-dropdown-item >修改密码</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>

        </el-header>
        <!--      主体-->
        <el-main>
          <div style="display: flex">
            <el-card style="width: 50%; margin-right: 10px">
              <div slot="header" class="clearfix">
                <span>2024毕设练习</span>
              </div>
              <div>2024毕设正式开始！
                <div style="margin-top: 20px">
                  <div style="margin: 10px 0"><strong>主题色</strong></div>
                  <el-button type="primary">按钮</el-button>
                  <el-button type="success">按钮</el-button>
                  <el-button type="warning">按钮</el-button>
                  <el-button type="danger">按钮</el-button>
                  <el-button type="info">按钮</el-button>
                </div>
              </div>
            </el-card>
            <el-card style="width: 50%">
              <div slot="header" class="clearfix">
                <span>渲染用户数据</span>
              </div>
              <div>
                <el-table :data="userList" style="width: 100%">
                  <el-table-column label="id" prop="id" width="80"></el-table-column>
                  <el-table-column label="用户名" prop="username" width="80"></el-table-column>
                  <el-table-column label="姓名" prop="name" width="80"></el-table-column>
                  <el-table-column label="地址" prop="address" width="80"></el-table-column>
                  <el-table-column label="邮箱" prop="email" width="80"></el-table-column>
                  <el-table-column label="手机号" prop="phone" width="80"></el-table-column>
                </el-table>
              </div>

            </el-card>

          </div>

        </el-main>

      </el-container>

    </el-container>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import axios from 'axios'
import request from '@/utils/request'

export default {
  name: 'HomeView',
  components: {
    HelloWorld
  }
  ,
  data() {
    return {
      isCollapse: false,
      asidwidth: '200px',
      collapseiocn: 'el-icon-s-fold',
      userList: []

    }
  },

  mounted() {
    // axios.get('http://localhost:8080/user/selectAll').then(res => {
    //   this.userList = res.data.data//获取数据库数据返回给userList
    // })
    request.get('/user/selectAll', ).then(res => {
     this.userList=res.data//获取数据库数据返回给userList
    })
  },

  methods: {
    logout() {
      localStorage.removeItem('honey-token')//清除token
      this.$router.push('/login')//跳转登录页面
    },

    handlecollapse() {
      this.isCollapse = !this.isCollapse;//取反
      if (this.isCollapse) {
        this.asidwidth = '60px';
      } else {
        this.asidwidth = '200px'
      }
      this.collapseiocn = this.isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold';
    }
  },
}
</script>
<style>
* {
  margin: 0;
  padding: 0;
}

.logo-title {
  margin-left: 10px !important;
  font-size: 20px !important;
  transition: all .3s !important;
}

.el-menu--inline {
  background-color: #1f2341 !important;
}

.el-menu--inline .el-menu-item {
  background-color: #1f2341 !important;
  padding-left: 45px !important;
}

.el-menu-item:hover {
  color: #fff !important;
}

.el-menu-item:hover, .el-submenu__title:hover {
  color: #fff !important;
}

.el-submenu__title:hover i {
  color: #fff !important;
}

.el-menu-item.is-active {
  background-color: #40a9ff !important;
  border-radius: 10px !important;;
  margin: 3px !important;;

}

.el-menu-item {
  height: 40px !important;;
  line-height: 40px !important;;
  margin: 3px !important;;
}

.el-submenu__icon-arrow {
  position: relative !important;
  right: -30px !important;
  top: 2px !important;
}

.el-aside {
  transition: width .3s !important;
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35) !important;
}

.el-header {
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35) !important;
}


</style>
